package com.xdf.data_transmitter.service;

import com.xdf.data_transmitter.dao.erp.UploadProcessMapper;
import com.xdf.data_transmitter.model.PlanProcess;
import com.xdf.data_transmitter.model.UploadProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UploadProcessServiceImpl implements UploadProcessService {

    @Autowired
    private UploadProcessMapper dao;

    @Override
    public int deleteByPrimaryKey(Integer iid) {
        return dao.deleteByPrimaryKey(iid);
    }

    @Override
    public int insert(UploadProcess record) {
        return dao.insert(record);
    }

    @Override
    public int insertSelective(UploadProcess record) {
        return dao.insertSelective(record);
    }

    @Override
    public UploadProcess selectByPrimaryKey(Integer iid) {
        return dao.selectByPrimaryKey(iid);
    }

    @Override
    public int updateByPrimaryKeySelective(UploadProcess record) {
        return dao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(UploadProcess record) {
        return dao.updateByPrimaryKey(record);
    }

    @Override
    public List<UploadProcess> getOrderPlanByProcessIId(Integer process_iid) {
        return dao.getOrderPlanByProcessIId(process_iid);
    }

    @Override
    public List<PlanProcess> getProcessByVatnum(String vat_num) {
        return dao.getProcessByVatnum(vat_num);
    }

    @Override
    public List<UploadProcess> selectByOrderIId(Integer order_iid) {
        return dao.selectByOrderIId(order_iid);
    }

    @Override
    public int save(UploadProcess record) {
        if( record == null ) return 0;
        Integer iid = record.getIid();
        iid = iid == null?0:iid;
        UploadProcess instance = selectByPrimaryKey(iid);
        if( instance == null )
            return insertSelective(record);
        else
            return updateByPrimaryKey(record);
    }

    @Override
    public List<UploadProcess> selectSpecVatnum(int order_iid, int plan_iid) {
        return dao.selectSpecVatnum(order_iid,plan_iid);
    }

    @Override
    public List<UploadProcess> selectOrderAfterProcess(int order_iid, int process_index,Date releaseDate) {
        return dao.selectOrderAfterProcess(order_iid,process_index,releaseDate);
    }

    @Override
    public List<UploadProcess> selectByVatnum(String vat_num) {
        return dao.selectByVatnum(vat_num);
    }

    @Override
    public List<UploadProcess> getOrderPlanByVat(String vat_num, String process_name, Date dtrk) {
        return dao.getOrderPlanByVat(vat_num,process_name,dtrk);
    }
}
